//import and format psid data
clear all
do "$data/PSID/weights/J276674"
do "$data/PSID/weights/J276674_formats"

gen uniqid = ER30001*1000 + ER30002 //generation of uniqid identifier variable
duplicates report uniqid //no duplicates!
drop ER30002 ER30000 

ds uniqid, not
foreach var in `r(varlist)'{
	
	//fetch label
	local lab: variable label `var'
	
	//kill sequence/release/interview numbers
	if strpos("`lab'", "SEQUENCE") | strpos("`lab'", "RELEASE") | strpos("`lab'", "INTERVIEW") |  strpos("`lab'", "RELATION"){
		drop `var'
		continue
	}
}
ds uniqid, not
foreach var in `r(varlist)'{
	di "`var'"
}

ren ER33438 weight_1997
ren ER33547 weight_1999
ren ER33639 weight_2001 
ren ER33742 weight_2003
ren ER33849 weight_2005
ren ER33951 weight_2007 
ren ER34046 weight_2009
ren ER34155 weight_2011
ren ER34269 weight_2013
ren ER34414 weight_2015
ren ER34651 weight_2017

local even `"1996 1998 2000 2002 2004 2006 2008 2010 2012 2014 2016"'
foreach num in `even'{
	local plus = `num' + 1
	gen weight_`num' = weight_`plus'
}

reshape long weight_, i(uniqid) j(year)
ren weight weight
save "$temp/psid_weights", replace



//end of dofile